<?php

$current_url = strpos($__url,'admin')===0 ? substr($__url,6) : $__url;


$have_selected = false;
$index_url = null;

$item_pattern = '<li class="menu-leaf %2$s"><a href="%1$s" %4$s>%3$s</a></li>';
$nohref_item_pattern = '<li class="menu-leaf %2$s"><span %4$s>%3$s</span></li>';
$container_pattern = '<!-- crumbs --><ul class="menu dropdown">%s</ul><!-- /crumbs -->';

if (count($items)<2)
	return;

$out = array();
foreach ( $items as $i ) :

	$active = false;

	if (!empty($i['mlink']))
		$i['class'] = (!empty($i['class']) ? $i['class'] : '' )
			. ' mlink ' . $i['mlink'] . '-mlink';

	$attrs = '';
	foreach( array( 'title', 'target', 'class' ) as $attr )
	if( isset( $i[$attr] ) )
		$attrs .= sprintf( ' %s="%s"', $attr, $this->escape($i[$attr]) );

	$href = !empty($i['href']) ? site_url( $i['href'] ) : null;
	$class = (isset($i['current'])&&$i['current'] ? 'selected' : '')
		. ' ' . ($i['href'] == '/' ? 'root' : '')
		. ' ' . (!empty($i['item_class']) ? $i['item_class'] : '')
		. ' ' . (false !== strpos($attrs,'link') ? ' menu-pin' : '');
	$text = $this->escape( $i['text'] );

	if (strpos($attrs,' title="') === false && strpos($class,'menu-pin') !== false)
		$attrs .= sprintf( ' title="%s"', $text );

	$out[] = sprintf( $href ? $item_pattern : $nohref_item_pattern, $href, $class, $text, $attrs );

endforeach;

echo sprintf( $container_pattern, join( $delimiter, $out ) );
